package LeetCode.month01.day11;

import java.util.Deque;
import java.util.LinkedList;

public class No136 {
    public int singleNumber(int[] nums) {
        Deque<Integer> deque = new LinkedList<>();
        for (int i = 0; i < nums.length; i++) {
            if(deque.contains(nums[i])){
                deque.remove(nums[i]);
            }else{
                deque.add(nums[i]);
            }
        }
        return deque.getFirst();
    }

    public int singleNumber2(int[] nums) {
        int sum = 0;
        int n = nums.length;
        for (int i = 0; i <n; i++) {
            sum ^= nums[i];
        }
        return sum;
    }
}
